package com.example.campus;

import java.io.IOException;
import java.net.MalformedURLException;
import java.util.ArrayList;

import com.news.m.NewsDAO;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class NewsBaseAdapter extends BaseAdapter {
	ArrayList<NewsDAO> list;
	Context context;

	public NewsBaseAdapter(Context context, ArrayList<NewsDAO> list) {
		this.list = list;
		this.context = context;

	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View from = LayoutInflater.from(context).inflate(R.layout.item, null);
		convertView = from;
		TextView title = (TextView) from.findViewById(R.id.item_news_title);
		TextView time = (TextView) from.findViewById(R.id.item_news_time);
		TextView sub = (TextView) from.findViewById(R.id.item_news_content);

		title.setText(list.get(position).name);
		time.setText(list.get(position).date);
		sub.setSingleLine();
        sub.setText("");
		return from;
	}

	final class ViewHolder {
		public TextView title;
		public TextView time;
		public TextView sub;

	}

}
